import Logger from '../util/Logger'

const TAG: string = 'DistributedDataModel'

export class DistributedDataModel {
  public isOver: boolean = false
  public step: number = 0
  public chessMapArr: Array<Array<string>> = []
  public chessX: number = -1
  public chessY: number = -1
  public fallGather: Array<Array<number>> = []
  public clickCount: number = 0
  public fallLocation: Array<number> = []

  constructor(isOver: boolean) {
    this.isOver = isOver
  }

  init() {
    Logger.info(TAG, 'gobangtest init')
    this.isOver = false
    for (let i = 0; i < 11; i++) {
      this.chessMapArr[i] = []
      for (let j = 0; j < 11; j++) {
        this.chessMapArr[i][j] = ''
      }
    }
    this.chessX = -1
    this.chessY = -1
  }

  fallChess(x: number, y: number, color: string, step: number, clickCount: number) {
    Logger.info(TAG, 'gobangtest fallChess entry')
    this.chessMapArr[x][y] = color
    this.chessX = x
    this.chessY = y
    this.step = step
    this.clickCount = clickCount
  }
}
